﻿using IronLua.Runtime;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace IronLua
{
    public sealed class Thread
        : ILuaDynamicObject
    {
        internal readonly LuaEnvironment Environ;
        internal readonly Thread Parent;
        internal readonly Stack Stack;
        internal readonly CallFrameCollection Frames;
        internal int ProgramCounter;

        public Thread(LuaEnvironment environ, Thread parent = null)
        {
            this.Environ = environ;
            this.Parent = parent;
            this.Stack = new Stack(this);
            this.Frames = new CallFrameCollection(this);
            this.ProgramCounter = 0;
        }

        internal CallFrame CurrentFrame { get { return this.Frames.Current; } }
        
        ValueType   ILuaDynamicObject.Type { get { return ValueType.Thread; } }
        ITable      ILuaDynamicObject.Metatable { get; set; }
    }
}
